import request from '@/utils/request'

// 查询公文列表
export function listDocument(query) {
  return request({
    url: '/workflow/document/page',
    method: 'get',
    params: query
  })
}

// 查询公文详情
export function getDocument(id) {
  return request({
    url: '/workflow/document/' + id,
    method: 'get'
  })
}

// 新增公文
export function addDocument(data) {
  return request({
    url: '/workflow/document',
    method: 'post',
    data: data
  })
}

// 修改公文
export function updateDocument(data) {
  return request({
    url: '/workflow/document',
    method: 'put',
    data: data
  })
}

// 提交公文
export function submitDocument(id) {
  return request({
    url: '/workflow/document/submit/' + id,
    method: 'post'
  })
}

// 取消公文
export function cancelDocument(id) {
  return request({
    url: '/workflow/document/cancel/' + id,
    method: 'post'
  })
}

// 签发公文
export function issueDocument(id) {
  return request({
    url: '/workflow/document/issue/' + id,
    method: 'post'
  })
}

// 归档公文
export function archiveDocument(id) {
  return request({
    url: '/workflow/document/archive/' + id,
    method: 'post'
  })
}

// 传阅公文
export function circulateDocument(id, userIds) {
  return request({
    url: '/workflow/document/circulate/' + id,
    method: 'post',
    data: userIds
  })
}

// 上传附件
export function uploadDocumentAttachment(data) {
  return request({
    url: '/workflow/document/upload',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 获取我的公文列表
export function getMyDocuments(query) {
  return request({
    url: '/workflow/document/my',
    method: 'get',
    params: query
  })
}